package com.mica.erp.contract.action;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.mica.erp.contract.model.ContractGood;
import com.mica.erp.contract.service.ContractGoodService;
import com.mica.generic.GenericAction;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.Preparable;

public class ContractGoodAction extends GenericAction implements Preparable,ModelDriven<ContractGood>{

	/**
	 * 
	 */
	private static final long serialVersionUID = 4853110974796663206L;

	@Override
	public String execute() throws Exception {
		cgList = contractGoodService.findContractGoods(contractGood);
		return SUCCESS;
	}

	public String saveCGood()throws Exception{
		this.contractGoodService.saveContractGood(contractGood);
		return SUCCESS;
	}
	
	public String delCGood()throws Exception{
		Long cgId = this.contractGood.getCgId();
		this.contractGoodService.delContractGood(cgId);
		return SUCCESS;
	}
	
	@Autowired
	private ContractGoodService contractGoodService;
	private List<ContractGood> cgList;
	private ContractGood contractGood;
	public void setContractGood(ContractGood contractGood) {
		this.contractGood = contractGood;
	}

	public List<ContractGood> getCgList() {
		return cgList;
	}

	@Override
	public ContractGood getModel() {
		return contractGood;
	}

	@Override
	public void prepare() throws Exception {
		contractGood = new ContractGood();
	}
	
	
}
